Skip to content

feat(SSH): wrapper library #5314#5315

Merged
matejk merged 8 commits intomainfrom
5314-ssh-wrapper-lib
Apr 21, 2026
Merged

feat(SSH): wrapper library #5314#5315
matejk merged 8 commits intomainfrom
5314-ssh-wrapper-lib

Conversation

@aleks-f
Copy link
Copy Markdown
Member

@aleks-f aleks-f commented Apr 13, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Poco::SSH wrapper library (client/server utilities built on libssh), plus a CppUnit testsuite and a sample CLI client.

Changes:

  • Registers the new SSH component and adds build/packaging files (CMake + Makefiles).
  • Introduces Poco::SSH core APIs: SSHServer, SSHSession, SSHClient, SSHHostKeyManager, SSHChannelStream, and exceptions.
  • Adds a testsuite (SSH-testrunner) and a pocossh sample client.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
components Registers SSH as a top-level component.
SSH/CMakeLists.txt Builds/install/packages the new SSH library and conditionally adds tests/samples.
SSH/Makefile Adds make-based build for PocoSSH and links against libssh.
SSH/cmake/PocoSSHConfig.cmake CMake package config for downstream find_package(PocoSSH).
SSH/dependencies Declares dependency on Foundation.
SSH/include/Poco/SSH/SSH.h Defines export macros and auto-link behavior for the SSH library.
SSH/include/Poco/SSH/SSHChannelStream.h Declares stream wrappers and sshReadLine() helper.
SSH/include/Poco/SSH/SSHClient.h Declares SSH client wrapper API.
SSH/include/Poco/SSH/SSHException.h Declares SSH-specific exception types.
SSH/include/Poco/SSH/SSHHostKeyManager.h Declares host key creation/loading utility.
SSH/include/Poco/SSH/SSHServer.h Declares SSH server wrapper and session tracking.
SSH/include/Poco/SSH/SSHServerConfig.h Declares server configuration struct and auth callback.
SSH/include/Poco/SSH/SSHSession.h Declares server-side session handler base class.
SSH/src/SSHChannelStream.cpp Implements ostream/channel bridge and line reader helper.
SSH/src/SSHClient.cpp Implements the client wrapper (connect/auth/channel).
SSH/src/SSHException.cpp Implements SSH exception classes.
SSH/src/SSHHostKeyManager.cpp Implements Ed25519 host key generation/validation.
SSH/src/SSHServer.cpp Implements server listen/accept loop, shutdown, and session tracking.
SSH/src/SSHSession.cpp Implements key exchange, authentication, channel negotiation, and cleanup.
SSH/samples/CMakeLists.txt Adds SSH sample(s) to the build.
SSH/samples/pocossh/CMakeLists.txt Builds the pocossh sample client.
SSH/samples/pocossh/Makefile Make-based build for pocossh sample.
SSH/samples/pocossh/src/pocossh.cpp Adds an interactive SSH CLI client sample.
SSH/testsuite/CMakeLists.txt Adds CTest integration for SSH tests.
SSH/testsuite/Makefile Make-based build for SSH testsuite runner.
SSH/testsuite/src/Driver.cpp Adds console test runner main() for SSH tests.
SSH/testsuite/src/SSHTest.cpp Adds integration-style tests for server/client/auth/channel behavior.
SSH/testsuite/src/SSHTest.h Declares SSH test case class.
SSH/testsuite/src/SSHTestSuite.cpp Defines SSH test suite composition.
SSH/testsuite/src/SSHTestSuite.h Declares SSH test suite entry point.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SSH/src/SSHServer.cpp
Comment thread SSH/src/SSHClient.cpp
Comment thread SSH/testsuite/src/SSHTest.cpp
Comment thread SSH/src/SSHSession.cpp
Comment thread SSH/src/SSHServer.cpp Outdated
Comment thread SSH/src/SSHSession.cpp
Comment thread SSH/testsuite/src/SSHTest.cpp Outdated
Comment thread SSH/testsuite/src/Driver.cpp Outdated
Comment thread SSH/src/SSHHostKeyManager.cpp Outdated
Comment thread SSH/src/SSHChannelStream.cpp
@aleks-f aleks-f linked an issue Apr 13, 2026 that may be closed by this pull request
@aleks-f aleks-f added this to the Release 1.16.0 milestone Apr 13, 2026
@aleks-f aleks-f requested a review from matejk April 14, 2026 10:05
@matejk matejk force-pushed the 5314-ssh-wrapper-lib branch from 9218b70 to 2398afb Compare April 20, 2026 19:43
aleks-f and others added 6 commits April 21, 2026 08:26
Use pkg-config on Darwin to locate libssh headers/libs,
replace deprecated ssh_pki_generate with ssh_pki_generate_key
(libssh >= 0.11), and fix accept loop hang on macOS by using
poll() instead of relying on shutdown() to unblock accept()
ssh_pki_generate_key was introduced in libssh 0.12.0, not 0.11.0;
correct the version guard so builds against 0.11.x (vcpkg baseline
on windows-2025) fall back to ssh_pki_generate.

On Windows, shutdown() alone does not reliably unblock libssh's
internal poll, so server shutdown with an active session hangs.
Follow shutdown() with closesocket() to force the session's blocking
read to error out and the session thread to exit.
@matejk matejk force-pushed the 5314-ssh-wrapper-lib branch from 2398afb to 20f6961 Compare April 21, 2026 06:26
CI (Windows, windows-2025-msvc-cmake only):
- Single OpenSSL source via vcpkg (remove the second FireDaemon install).
- Pre-install scrub of stale runner-image OpenSSL/OpenSSH and cached
  vcpkg ports. Fixed-path assertions on DLLs/libs/headers plus
  legacy.dll. Post-install Get-Command check that libcrypto, libssl,
  ssh, and legacy DLLs resolve under the vcpkg bin dir.
- Post-job vcpkg remove in if: always() step.
- Pass --vcpkg-root=$VCPKG_INSTALLATION_ROOT to silence the
  VCPKG_ROOT mismatch warning from the VS-bundled vcpkg.
- vcpkg binary cache via actions/cache@v5 on %LOCALAPPDATA%/vcpkg/archives.

SSH library:
- Switch from hand-written cmake/FindLibSSH.cmake to upstream
  find_package(libssh CONFIG); link against imported target ssh.
  Drops 73-line module; works across apt libssh-dev (Debian 12+,
  Ubuntu), brew libssh, and vcpkg libssh.
- Pin classical KEX (curve25519/ecdh/dh-group16/14) in testsuite to
  work around libssh 0.12.0 ML-KEM hybrid KEX bug on MSVC x64
  (upstream fix landed post-0.12.0 tag and is not yet in vcpkg's
  libssh port).

Code review (clang-tidy-21 + manual):
- acceptLoop: retry on EINTR instead of breaking.
- authenticate(): bound total messages (10x maxAuthAttempts).
- disconnectAllSessions: SHUT_RDWR/SD_BOTH instead of magic 2.
- SSHHostKeyManager::generateKey: UmaskGuard RAII.
- SSHClient::authenticatePublicKey: initialized rc.
- Sample pocossh: ssize_t for read/write, zero-init pollfd/termios,
  explicit stub on Windows where the interactive loop is absent.
- '= default' for trivial destructors; Driver uses reserve + emplace_back.
- ASCII-only comments; #if defined / #if !defined throughout SSH/.
@matejk matejk force-pushed the 5314-ssh-wrapper-lib branch from 8ce887f to 493762b Compare April 21, 2026 13:33
Extend the actions/cache step to cover C:\vcpkg\downloads alongside
the binary archives. The downloads dir holds source tarballs (openssl,
libssh, ...) and tool installs (cmake, ninja, perl, powershell-core)
that vcpkg re-downloads on every ABI-miss rebuild; persisting them
avoids the ~30-60s cmake/powershell/perl zip download on every run
where the binary cache misses.

Key prefix renamed vcpkg-archives- -> vcpkg- since it now covers more
than just archives. Old cache entries will be orphaned and LRU-evicted.
Copy link
Copy Markdown
Contributor

@matejk matejk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated CI and removed custom cmake files and rather used provided ones.

@matejk matejk merged commit c8dd017 into main Apr 21, 2026
52 checks passed
@matejk matejk deleted the 5314-ssh-wrapper-lib branch April 21, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH wrapper library

3 participants